package com.xuecheng.system.convert;

import com.xuecheng.api.sysetm.model.dto.CourseCategoryDTO;
import com.xuecheng.api.sysetm.model.dto.DictionaryDTO;
import com.xuecheng.system.entity.Dictionary;
import com.xuecheng.system.entity.ex.CourseCategoryNodes;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface SystemConvert {
    //构建属性转换器
    SystemConvert INSTANCE = Mappers.getMapper(SystemConvert.class);

    //Dictionary === po--->>dto
    @Mapping(source = "id",target = "dictionaryId")
    DictionaryDTO entity2Dto(Dictionary po);

    List<DictionaryDTO> entitys2Dtos(List<Dictionary> poList);

    //Dictionary ===  dto--->>po
    @Mapping(source = "dictionaryId",target = "id")
    Dictionary dto2Entity(DictionaryDTO dto);

    List<Dictionary> dtos2Entitys(List<DictionaryDTO> poList);



    //Category=== po--->dto
    @Mappings({
            @Mapping(source = "id",target = "courseCategoryId"),
            @Mapping(source = "childrenTreeNodes",target = "categoryTreeNodes")
    })
    CourseCategoryDTO po2Dto(CourseCategoryNodes nodes);

    List<CourseCategoryDTO> pos2Dtos(List<CourseCategoryNodes> list);








}
